package com.fs.base.pojo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import org.hibernate.annotations.Formula;

import com.fs.base.annotation.ColumnDesc;
import com.fs.base.annotation.EasyUiComboBox;

/**
 * @author TiddlerCJ
 * @desc 系统组织结构
 */
@Entity
@Table(name="s_org")
@NoArgsConstructor
@AllArgsConstructor
@EasyUiComboBox(valueField="orgNo")
@Data@EqualsAndHashCode(callSuper=false) 
public class Org extends PkEntity{
	@ColumnDesc(name="组织名称") 
	private String orgName;
	
	@ColumnDesc(name="组织编码") 
	private String orgNo;
	
	@ColumnDesc(name="组织排序")
	private Integer orgOrder;
	
	private String orgType;		//分类
	
	@ColumnDesc(name="父组织") 
	private String parentId;
	
	/*
	 * 关联查询父组织名称
	 */
	@Formula("( SELECT c.org_name FROM s_org c WHERE c.id = parent_id )")
	private String parentName;
	
	//主负责人
	private String orgLeader;
	
	@Formula("( SELECT c.nick_name FROM s_user c WHERE c.id = org_leader )")
	private String  orgLeaderName;
	
	//用户组排序
	private Integer groupOrder;
	
	//用户组成员
	@Column(columnDefinition="varchar(990) COMMENT '用户组成员' ")
	private String orgMembers;
	
	@Formula("( SELECT group_concat(e.nick_name) FROM s_user e WHERE  find_in_set(e.id,  org_members) )")
	private String  orgMembersName;
}
